﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CNVP.Framework.Utils;

namespace CNVP.JShop.Web.Admin.CommonWindows
{
    public partial class AjaxProDetailNum : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string IDS = Request.QueryString["IDS"];
            string CompareValue = Request.QueryString["CompareValue"];
            if (string.IsNullOrEmpty(CompareValue) || !Public.IsNumber(CompareValue))
            {
                CompareValue = "0";
            }
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(IDS))
                {
                    string[] IDSArray = IDS.Split(Convert.ToChar("_"));
                    if (IDSArray[1] != "0")
                    {
                        var model_ProductsDetail = new BLL.CNVP_ProductsDetail().GetSingle_CNVP_ProductsDetailById(Convert.ToInt32(IDSArray[1]));
                        if (model_ProductsDetail != null)
                        {
                            if (Convert.ToInt32(CompareValue) > model_ProductsDetail.StockNum)
                            {
                                Response.Write(0);
                            }
                            else
                            {
                                Response.Write(1);
                            }
                        }
                    }
                    else
                    {
                        var model_Products = new BLL.CNVP_Products().GetSingle_CNVP_ProductsById(Convert.ToInt32(IDSArray[0]));
                        if (model_Products != null)
                        {
                            if (Convert.ToInt32(CompareValue) > model_Products.StockTotalNum)
                            {
                                Response.Write(0);
                            }
                            else
                            {
                                Response.Write(1);
                            }
                        }
                    }
                }
            }
        }
    }
}